// pages/test/test.js
//获取应用实例
const app = getApp()
Page({
  data: {
    latitude: '',
    longitude: '',
    speed: '',
    accuracy: '',
    altitude: '',
    verticalAccuracy: '',
    horizontalAccuracy: ''
  },
  getLocation: function () {
    var _this = this;
    wx.getLocation({
      type: 'wgs84',
      altitude: true,//传入 true 会返回高度信息，由于获取高度需要较高精确度，会减慢接口返回速度。传入false就把altitude属性删掉
      isHighAccuracy: true,
      highAccuracyExpireTime: 5000,
      success: function (res) {
        var latitude = res.latitude
        var longitude = res.longitude
        var speed = res.speed
        var accuracy = res.accuracy
        var altitude = res.altitude
        var verticalAccuracy = res.verticalAccuracy
        var horizontalAccuracy = res.horizontalAccuracy
        _this.setData({
          latitude: latitude,
          longitude: longitude,
          speed: speed,
          accuracy: accuracy,
          altitude: altitude,
          verticalAccuracy: verticalAccuracy,
          horizontalAccuracy: horizontalAccuracy
        })
      },
      complete :function(r){
        console.log(r)
      }
    })
  }
})
